<?php

namespace app\api\validate;

use think\Validate;

class OrderValidate extends Validate
{
    protected $regex = ['phone' => '/^1[3456789]\d{9}|([0-9]{3,4}-)?[0-9]{7,8}$/'];

    protected $rule = [
        'category' => 'require',
        'reserve_time' => 'require|dateFormat:Y-m-d H:i:s',
        'province' => 'require',
        'city' => 'require',
        'district' => 'require',
        'address' => 'require',
        'longitude' => 'require',
        'latitude' => 'require',
        'real_name' => 'require',
        'mobile' => 'require|regex:phone',
        'estimate_weight' => 'require',
        'estimate_price' => 'require',
        'pay_type' => 'require|in:1,2',
//        'service_fee' => 'require',

        'order_id' => 'require|gt:0',
        'money' => 'require|gt:0',

        'goods_id' => 'require|gt:0',

    ];

    protected $message = [
        'category.require' => '分类不能为空',
        'reserve_time.require' => '预约时间不能为空',
        'reserve_time.dateFormat' => '预约时间格式错误',
        'province.require' => '省份不能为空',
        'city.require' => '城市不能为空',
        'district.require' => '区/县不能为空',
        'address.require' => '详细地址不能为空',
        'longitude.require' => '经度不能为空',
        'latitude.require' => '纬度不能为空',
        'real_name.require' => '联系人不能为空',
        'mobile.require' => '手机号不能为空',
        'mobile.phone' => '手机号格式错误',
        'estimate_weight.require' => '预估重量不能为空',
        'estimate_price.require' => '预估价格不能为空',
        'pay_type.require' => '结算类型不能为空',
        'pay_type.in' => '结算类型格式错误',
//        'service_fee.require' => '服务费不能为空',

        'order_id.require' => '订单id不能为空',
        'money.require' => '金额不能为空',
        'money.gt' => '金额格式错误',

        'goods_id.require' => '服务产品id不能为空',
        'goods_id.gt' => '服务产品id格式错误',
    ];

    /**
     * 验证场景
     * @var array
     */
    protected $scene = [
        'create' => ['category', 'reserve_time', 'address', 'real_name', 'mobile', 'estimate_weight', 'estimate_price', 'longitude', 'latitude', 'province', 'city', 'district'], //创建
        'complete' => ['order_id', 'money', 'pay_type'],
        'home_create' => ['goods_id', 'reserve_time', 'address', 'real_name', 'mobile'], //家政订单创建


    ];


}